#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m, c;
int head[N << 1];
int ver[N << 2], W[N << 2], Next[N << 2], tot;
int id(int d, int x) { return (d - 1) * n + x; }
void add(int u, int v, int w) {
  ++tot;
  ver[tot] = v;
  W[tot] = w;
  Next[tot] = head[u];
  head[u] = tot;
}
ll dis[N << 1];
void dijkstra() {
  memset(dis, 0x3f, sizeof(dis));
  priority_queue<pli, vector<pli>, greater<pli>> pq;
  pq.push(pli(0, 1));
  dis[1] = 0;
  while (pq.size()) {
    pli now = pq.top();
    pq.pop();
    ll d = now.first;
    int u = now.second;
    if (d > dis[u]) continue;
    for (int i = head[u]; i; i = Next[i]) {
      int v = ver[i];
      int w = W[i];
      if (dis[v] > dis[u] + w) {
        dis[v] = dis[u] + w;
        pq.push(pli(dis[v], v));
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> c;
  rep(i, 1, m) {
    int u, v;
    cin >> u >> v;
    add(id(1, u), id(1, v), 1);
    add(id(2, v), id(2, u), 1);
  }
  rep(i, 1, n) {
    add(id(1, i), id(2, i), c);
    add(id(2, i), id(1, i), c);
  }
  dijkstra();
  cout << min(dis[id(1, n)], dis[id(2, n)]);
  return 0;
}